package com.pureut.system.controller;

import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.security.annotation.RequiresPermissions;
import com.pureut.system.domain.SysWorkbenchMessage;
import com.pureut.system.domain.dto.SysWorkbenchMessageDto;
import com.pureut.system.domain.vo.SysWorkbenchMessageVo;
import com.pureut.system.service.SysWorkbenchMessageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 消息提醒（工作台）控制层
 */
@RestController
@RequestMapping("/workbench-message")
public class SysWorkbenchMessageController extends BaseController {

    /**
     * 消息提醒service
     */
    @Resource
    SysWorkbenchMessageService sysWorkbenchMessageService;

    /**
     * 消息提醒分页列表
     * @param sysWorkbenchMessageVo
     * @return
     */
//    @RequiresPermissions("system:message:list")
    @GetMapping("/list")
    public TableDataInfo list(SysWorkbenchMessageVo sysWorkbenchMessageVo) {
        startPage();
        List<SysWorkbenchMessageDto> list = sysWorkbenchMessageService.getList(sysWorkbenchMessageVo);
        return getDataTable(list);
    }

    /**
     * 修改
     */
//    @RequiresPermissions("system:message:update")
    @PutMapping("/updateStatus")
    public AjaxResult updateStatus(@RequestBody SysWorkbenchMessageVo sysWorkbenchMessageVo) {
        return toAjax(sysWorkbenchMessageService.updateStatus(sysWorkbenchMessageVo));
    }

    /**
     * 新增(feign)
     */
    @PostMapping("/insertWork")
    public AjaxResult insertWork(@RequestBody List<SysWorkbenchMessageVo> list) {
        return toAjax(sysWorkbenchMessageService.insertWork(list));
    }

    /**
     * 查询最近一次库存量和物料编码的数据
     */
    @GetMapping("/getInfo")
    public List<SysWorkbenchMessage> getInfo(String type) {
        return sysWorkbenchMessageService.getInfo(type);
    }

    /**
     * 查询未读消息数量
     */
    @GetMapping("/getNoMessage")
    public int getNoMessage() {
        return sysWorkbenchMessageService.getNoMessage();
    }
}
